package com.segersten.othello.service.akka;

import com.segersten.othello.service.akka.lobby.DomainPlayer;

public class Player {
	
	private String nickname;
	private Auth auth;
	
	public Player() {	
	}

	public Player(String nickname, Auth auth) {
		this.nickname = nickname;
		this.auth = auth;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public Auth getAuth() {
		return auth;
	}

	public void setAuth(Auth auth) {
		this.auth = auth;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((auth == null) ? 0 : auth.hashCode());
		result = prime * result
				+ ((nickname == null) ? 0 : nickname.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Player other = (Player) obj;
		if (auth == null) {
			if (other.auth != null)
				return false;
		} else if (!auth.equals(other.auth))
			return false;
		if (nickname == null) {
			if (other.nickname != null)
				return false;
		} else if (!nickname.equals(other.nickname))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Player [nickname=" + nickname + ", auth=" + auth + "]";
	}

    public DomainPlayer domainPlayer()
    {
        return new DomainPlayer(auth.getDomain(), nickname);
    }
	
	
}
